<?php
    if(isset($_GET['id']))
    {
        $id = $_GET['id'];
        require_once('../Database/Database.php');
        $db = new Database();
        $db->Connect();
        $shortcut = $db->SelectColumns('Series', 'Shortcut', 'ID_Series = ' . $id);
        $db->Disconnect();
        if($shortcut)
        {
            $shortcut = $shortcut[0]->Shortcut;
?>
<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" type="text/css" href="css/default.css" />
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Fahrer | Ranking - ALPHA</title>
    </head>
    <body>
        <div id="header">Fahrer</div>
        <div id="main">
            <table>
                <tr>
                    <td>Name</td>
                    <td>Nummer</td>
                    <td>Fahrzeug</td>
                    <td>Team</td>
                </tr>
                <?php
                    $drivers = $db->Select($shortcut . '_drivers');

                    foreach($drivers as $driver)
                    {
                        // Fahrer ohne Startlizenz -> inaktiv..
                        if($driver->Active != 0)
                        {
                            echo '<tr class="active_driver">';
                        }
                        else
                        {
                            echo '<tr class="inactive_driver">';
                        }

                        $name_string = '<a href="../../index.php?option=com_users&view=profile&user_id=' . $driver->JID .
                                '" target="_blank">' . htmlentities($driver->Name) . '</a>';

                        echo '<td>' . $name_string . '</td>';
                        echo '<td>' . $driver->Number . '</td>';

                        $vehicle = $db->Select($shortcut . '_vehicles', 'ID_Vehicle = ' . $driver->Vehicle_ID);
                        echo '<td>' . $vehicle[0]->Name . '</td>';

                        $team = $db->Select($shortcut . '_teams', 'ID_Team = ' . $driver->Team_ID);
                        echo '<td>' . $team[0]->Name . '</td>';

                        echo '</tr>';
                    }
                    $db->Disconnect();
                ?>
            </table>
            <div id="hint">Fahrer ohne Startberechtigung sind ausgegraut.</div>
        </div>
        <div id="footer"></div>

    </body>
</html>
<?php
        }
        else
        {
            echo 'Ung&uuml;ltige Serien ID.';
        }
    }
    else
    {
        echo 'ERROR';
    }
?>